<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Symbol创建对象属性</title>
</head>
<body>
  <script>
    // 向对象中添加方法  up down
    /* 
      let game = {
        name: "俄罗斯方块",
        up: function() {},
        down: function() {}
      }

      let methods =  {
        up: Symbol(),
        down: Symbol()
      };

      game[methods.up] = function() {
        console.log("我可以改变形状");
      }

      game[methods.down] = function() {
        console.log("我可以快速下降");
      }

      console.log(game);
      game[methods.up]() 
    */
    
    let youxi = {
      name: "狼人杀",
      say: function() {
        console.log("我不可以发言")
      },
      [Symbol('say')]: function() {
        console.log("我可以发言")
      },
      [Symbol('zibao')]: function() {
        console.log("我可以自爆")
      }
    }

    console.log(youxi);
    // 无法调用方法
    // youxi[Symbol('say')]()       // Uncaught TypeError: youxi[Symbol(...)] is not a function
    /* 
      let say = Symbol('say');
      youxi[say]();                   // Uncaught TypeError: youxi.say is not a function 
    */

    console.log(Reflect.ownKeys(youxi))
    youxi[Reflect.ownKeys(youxi)[2]]()
  </script>
</body>
</html>